#include <stdio.h>
#include <stdlib.h>

#include <cedule/log.h>
#include <cedule/debug.h>

#include "protocol.h"
#include "frame.h"

/*
 * initialize the state machine for current connexion
 *
 * init:
 * init -> auth (login request)
 * init -> init (connexion closed)
 * init -> init (error)
 *	
 * auth:
 * auth -> logged (password ok)
 * auth -> auth (password not ok & attempts < 3)
 * auth -> init (other cases)
 *
 * logged ->
 * logged -> ???
 */
Protocol_t * protocol_create( ) {
	Protocol_t * protocol;

	protocol = (Protocol_t *) malloc (sizeof( Protocol_t ));
	if ( !protocol ) goto error;

	protocol->state = PROTOCOL_STATE_NONE;

	return protocol;

error:
	if (protocol ) free( protocol );
	return NULL;
}

void protocol_destroy( Protocol_t * protocol ) {
	notimplemented();
}

int protocol_parse( Protocol_t* proto, Frame_t * frame ){
	notimplemented();		
	return 0;
}

